$(function(){



$(".col li").hover(function(){


	$(this).find(".mask1").toggleClass("chuxian1");
});




$("#lai li").on("mouseenter",function(){

	$(this).addClass("xuanzhong").siblings().removeClass("xuanzhong");
	$(".mask2").addClass("chuxian3");
	var num = $(this).index();
	$(".mask2 li").eq(num).addClass("chuxian2").siblings().removeClass("chuxian2");
});

$(".carousel-left").on("mouseleave",function(){

	$(".mask2").removeClass("chuxian3");
	$("#lai li").removeClass("xuanzhong");
	$(".mask2 li").removeClass("chuxian2");

});


$(window).on("blur",function(){
	clearInterval(timer);
	console.log("不动了吧");
});

$(window).on("focus",function(){
	clearInterval(timer);
	timer = setInterval(play,3000);
	console.log("又开了吧");
});

// $(".carousel-part").stop(true,true);

$(".carouesl").on("mouseenter",function(){

	clearInterval(timer);
	console.log("停止");
});

$(".carouesl").on("mouseleave",function(){

	timer = setInterval(play,3000);
	console.log("开始");
});



function cur(index2){
	$(".control-bottom li").eq(index2).addClass("current").siblings().removeClass("current");
}

var timer = null;
var index = 1;
var index2= 0;

function play(){
	index++;  
	index2++;  
	if(index > 5){
		index = 1;
		$(".carousel-part").css("left",0+"px");
		console.log("跳");
	}
	$(".carousel-part").stop().animate({
		"left": -index*958+"px"
	},800,"swing");
	console.log("走");
	if(index2 > 4){
		index2 = 0;
	}
	cur(index2);
}


	timer = setInterval(play,3000);


$(".control-bottom li").on("click",function(){
	var num = $(this).index();
	index2 = num;
	index = num+1;
	cur(index2);
	$(".carousel-part").stop().animate({
		"left": -index*958+"px"
	},800,"swing");
});

$("#dz").on("click",function(){
	index--;
	index2--;
	if(index < 0){
		index = 4;
		$(".carousel-part").css("left",-5*958+"px");
	}
	$(".carousel-part").stop().animate({
		"left": -index*958+"px"
	},800,"swing");
	if(index2 < 0){
		index2 = 4;
	}
		cur(index2);
});

$("#dy").on("click",function(){
	index++;  
	index2++;  
	if(index > 5){
		index = 1;
		$(".carousel-part").css("left",0+"px");
	}
	$(".carousel-part").stop().animate({
		"left": -index*958+"px"
	},800,"swing");
	if(index2 > 4){
		index2 = 0;
	}
	cur(index2);
});


var timer2 = null;
function play2(){
	$(".tuijian-part ul").toggleClass("left1210");
}
timer2 = setInterval(play2,5000);


$(".tuijian-part,#zbyb").on("mouseenter",function(){
	clearInterval(timer2);
});

$(".tuijian-part,#zbyb").on("mouseleave",function(){
	timer2 = setInterval(play2,5000);
});


$(".zb").on("click",function(){

	$(".tuijian-part ul").removeClass("left1210");
});

$(".yb").on("click",function(){

	$(".tuijian-part ul").addClass("left1210");
});

var shuju1 = {"xueyuan":{"0":
							{"img":"img/59bf622d735d0.jpg",
							  "p" :"人生没有太晚的开始"
							}
						},
				"keji":{"0":
							{"img":"img/mengxiang.jpg",
							  "p" :"梦想来啦"
							}
						},
				"aiyou":{"0":
							{"img":"img/tuzi.jpg",
							  "p" :"兔子来啦"
							}
						}
			};


$("#ppp a").on("mouseenter",function(){

	var who = $(this).data("who");
	console.log(who);
	$("#cq li").eq(0).find("img").prop("src",shuju1[who]["0"]["img"])
					.end().find("p").text(shuju1[who]["0"]["p"]);
					

});

$(".p-k-b-city li").on("mouseenter",function(){

	var num = $(this).index();

	$(".p-k-b-show .baoming").eq(num).addClass("chuxian2").siblings().removeClass("chuxian2");
});


$("#close").on("click",function(){
	$(".guanggao").css("display","none");
});



// var shei = $(".carousel-part")[0];
// var timer = null;
// var index = 0;

// timer = setInterval(function(){
//  	index++;
//  	if(index > 5){
//  		index = 1;
//  		$(".carousel-part").css("left",index);
//  	}
//  	yundong(shei,{"left":-958*index},8);
	
//  },3000);





})